package com.zuthub.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.zuthub.common.annotation.Log;
import com.zuthub.common.core.controller.BaseController;
import com.zuthub.common.core.domain.AjaxResult;
import com.zuthub.common.enums.BusinessType;
import com.zuthub.system.domain.SysProfessor;
import com.zuthub.system.service.ISysProfessorService;
import com.zuthub.common.utils.poi.ExcelUtil;
import com.zuthub.common.core.page.TableDataInfo;

/**
 * 专家管理Controller
 * 
 * @author zuthub
 * @date 2021-04-02
 */
@RestController
@RequestMapping("/system/professor")
public class SysProfessorController extends BaseController
{
    @Autowired
    private ISysProfessorService sysProfessorService;

    /**
     * 查询专家管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:professor:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysProfessor sysProfessor)
    {
        startPage();
        List<SysProfessor> list = sysProfessorService.selectSysProfessorList(sysProfessor);
        return getDataTable(list);
    }

    @GetMapping("/tourist")
    @CrossOrigin
    public TableDataInfo listForTourist(SysProfessor sysProfessor)
    {
        startPage();
        List<SysProfessor> list = sysProfessorService.selectSysProfessorList(sysProfessor);
        return getDataTable(list);
    }

    /**
     * 导出专家管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:professor:export')")
    @Log(title = "专家管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysProfessor sysProfessor)
    {
        List<SysProfessor> list = sysProfessorService.selectSysProfessorList(sysProfessor);
        ExcelUtil<SysProfessor> util = new ExcelUtil<SysProfessor>(SysProfessor.class);
        return util.exportExcel(list, "professor");
    }

    /**
     * 获取专家管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:professor:query')")
    @GetMapping(value = "/{professorId}")
    public AjaxResult getInfo(@PathVariable("professorId") Long professorId)
    {
        return AjaxResult.success(sysProfessorService.selectSysProfessorById(professorId));
    }

    /**
     * 新增专家管理
     */
    @PreAuthorize("@ss.hasPermi('system:professor:add')")
    @Log(title = "专家管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysProfessor sysProfessor)
    {
        return toAjax(sysProfessorService.insertSysProfessor(sysProfessor));
    }

    /**
     * 修改专家管理
     */
    @PreAuthorize("@ss.hasPermi('system:professor:edit')")
    @Log(title = "专家管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysProfessor sysProfessor)
    {
        return toAjax(sysProfessorService.updateSysProfessor(sysProfessor));
    }

    /**
     * 删除专家管理
     */
    @PreAuthorize("@ss.hasPermi('system:professor:remove')")
    @Log(title = "专家管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{professorIds}")
    public AjaxResult remove(@PathVariable Long[] professorIds)
    {
        return toAjax(sysProfessorService.deleteSysProfessorByIds(professorIds));
    }
}
